import { create } from 'zustand'
import { createSelectors } from '@/utils/createSelectors'

interface BearState {
  bears: number
  honey: {
    amount: number
  }
  increase: (by: number) => void
  increment: () => void
  addHoney: (by: number) => void
}

const useBearStoreBase = create<BearState>()((set) => ({
  bears: 0,
  honey: {
    amount: 100
  },
  increase: (by) => set((state) => ({ bears: state.bears + by })),
  increment: () => set((state) => ({ bears: state.bears + 1 })),
  addHoney: (by) => set((state) => ({
    honey: { amount: state.honey.amount + by }
  }))
}))

const useBearStore = createSelectors(useBearStoreBase)

export default useBearStore 